package grpc

import (
	"context"
	"gitlab.local/backend/proto/base"
	"gitlab.local/backend/proto/dto"
	"ota/bll"
	"ota/lib/trace_log"
	"ota/utils"
)

type Ota struct {
}

func (a *Ota) UpgradeResult(ctx context.Context, in *dto.UpgradeResultRequest, out *dto.UpgradeListResultResponse) error {

	out = &dto.UpgradeListResultResponse{}
	return nil
}

// 获取升级的统计结果
func (a *Ota) UpgradeStatistics(ctx context.Context, in *dto.UpgradeStatisticsRequest, out *dto.UpgradeStatisticsResponse) error {

	out = &dto.UpgradeStatisticsResponse{}
	return nil
}

// 检测是否有版本升级
func (a *Ota) CheckVersion(ctx context.Context, in *dto.CheckVersionRequest, out *dto.CheckVersionResponse) error {

	out = &dto.CheckVersionResponse{}
	return nil
}

// 检测是否有版本升级
func (a *Ota) OfflineUpgrade(ctx context.Context, in *dto.OfflineUpgradeRequest, out *base.Empty) error {

	var err error
	trace_log.DebugLogger(in.Sn, "---- Request OfflineUpgrade in:", utils.ToJsonString(in))
	defer func() {
		trace_log.DebugLogger(in.Sn, "----Response OfflineUpgrade err", err)
	}()
	err = bll.OfflineUpgrade(ctx, in)
	out = &base.Empty{}
	return err
}
